package dao

import (
	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
	"github.com/wonderivan/logger"
)

var mysql *xorm.Engine

func GetMysql() (*xorm.Engine, error) {
	if mysql != nil {
		return mysql, nil
	}
	mysql, err := xorm.NewEngine("mysql", "admin:pubg.2020@tcp(pubg-db.cv3gvs0tnix0.ap-south-1.rds.amazonaws.com:3306)/payment?charset=utf8")
	if err != nil {
		logger.Fatal("Fail to create xorm engine: %v\n", err)
		return nil, err
	}
	return mysql, nil
}
